layui.use(['table', 'admin', 'ax', 'func'], function () {
    var $ = layui.$;
    var table = layui.table;
    var $ax = layui.ax;
    var admin = layui.admin;
    var func = layui.func;

    /**
     * 楼层费用管理
     */
    var FlowElevatorPrice = {
        tableId: "flowElevatorPriceTable"
    };

    /**
     * 初始化表格的列
     */
    FlowElevatorPrice.initColumn = function () {
        return [[
            {type: 'checkbox'},
            {field: 'levelId', hide: true, title: 'ID'},
            {field: 'levelName', sort: true, title: '楼层名称'},
            {field: 'note', sort: true, title: '备注'},
            {field: 'price', sort: true, title: '价格'},
            {field: 'createTime', sort: true, title: '创建时间'},
            {align: 'center', toolbar: '#tableBar', title: '操作'}
        ]];
    };

    /**
     * 点击查询按钮
     */
    FlowElevatorPrice.search = function () {
        var queryData = {};


        table.reload(FlowElevatorPrice.tableId, {
            where: queryData, page: {curr: 1}
        });
    };

     /**
      * 点击编辑
      *
      * @param data 点击按钮时候的行数据
      */
      FlowElevatorPrice.openEditDlg = function (data) {
          func.open({
              title: '修改楼层费用',
              content: Feng.ctxPath + '/flowStoreCity/flowElevatorPriceEdit?elevatorId='+data.levelId+'&storeCityId='+Feng.getUrlParam("storeCityId")+'&serviceTypeId=' + Feng.getUrlParam("serviceTypeId"),
              tableId: FlowElevatorPrice.tableId
          });
      };

    // 渲染表格
    var tableResult = table.render({
        elem: '#' + FlowElevatorPrice.tableId,
        url: Feng.ctxPath + '/flowStoreCity/flowElevatorPriceList?storeCityId='+Feng.getUrlParam("storeCityId")+'&serviceTypeId='+Feng.getUrlParam("serviceTypeId"),
        page: true,
        height: "full-158",
        cellMinWidth: 100,
        cols: FlowElevatorPrice.initColumn()
    });

    // 搜索按钮点击事件
    $('#btnSearch').click(function () {
        FlowElevatorPrice.search();
    });

    // 工具条点击事件
    table.on('tool(' + FlowElevatorPrice.tableId + ')', function (obj) {
        var data = obj.data;
        var layEvent = obj.event;

        if (layEvent === 'edit') {
            FlowElevatorPrice.openEditDlg(data);
        }
    });
});
